<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:72:"D:\Code\matian\matian\application\admin\view\bootstrap\weixin\index.html";i:1492154292;}*/ ?>
<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-10">
        <h2>微信菜单</h2>
        <ol class="breadcrumb">
            <li>
                <a href="#">首页</a>
            </li>

            <li class="active">
                <strong>微信菜单</strong>
            </li>
        </ol>
    </div>
</div>

<div class="wrapper wrapper-content animated fadeInRight ecommerce">
    <div class="ibox-content m-b-sm border-bottom" id="form1">
        <div class="row">
            <div class="col-sm-3">
                <div class="form-group">
                    <label class="control-label" for="title">菜单名称</label>
                    <input type="text" id="title" name="title" placeholder="菜单名称"
                           class="form-control">
                </div>
            </div>
            <div class="col-sm-3">
                <div class="form-group">
                    <label class="control-label">动作类型(type)</label>
                    <?php echo W('parts/op',['name'=>'type','key'=>'mat','value'=>'']); ?>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <a class="btn btn-success btn-outline" href="#<?php echo U('form'); ?>">
                    <i class="fa fa-edit"></i>
                    <span class="bold">添加</span>
                </a>
                &nbsp;
                &nbsp;
                <a class="btn btn-success btn-outline" href="javascript:void(0)" id="submitMenu">
                    <i class="fa fa-save"></i>
                    <span class="bold">提交菜单</span>
                </a>
                &nbsp;
                &nbsp;
                <!--<a class="btn btn-success btn-outline" href="javascript:void(0)" id="downMenu">-->
                    <!--<i class="fa fa-download"></i>-->
                    <!--<span class="bold">下载菜单</span>-->
                <!--</a>-->
            </div>
            <div class="col-sm-6 text-right">
                <button class="btn btn-default" data-op="reset">
                    <i class="fa fa-refresh"></i>
                    <span class="bold">重置</span>
                </button>
                &nbsp;
                &nbsp;
                <button class="btn btn-primary" data-op="search">
                    <i class="fa fa-search"></i>
                    <span class="bold">查询</span>
                </button>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-3">
            <div id="using_json"></div>
        </div>
        <div class="col-sm-9">
            <div class="ibox-content">
                <table class="footable table table-stripped toggle-arrow-tiny" id="footable">
                </table>
            </div>
        </div>
    </div>
</div>
<script>
    $(document).ready(function () {
        var table = YFootTable.create('#footable', {
            baseUrl: "<?php echo U('weixin/'); ?>",
            searchForm: '#form1',

            columns: [
                {name: 'title', title: '菜单名称', sortable: true}
                , {name: 'parent_title', title: '父菜单', sortable: true, breakpoints: 'xs sm md'}
                , {name: 'mat__type', title: '动作类型(type)', sortable: true, breakpoints: 'xs sm md'}
                , {name: 'key', title: '键值(key)', sortable: true, breakpoints: 'xs sm md lg'}
                , {name: 'media_id', title: '素材ID(media_id)', sortable: true, breakpoints: 'xs sm md lg'}
                , {name: 'url', title: '链接地址', sortable: true, breakpoints: 'xs sm md lg'}
                , {name: 'sort', title: '排序号', sortable: true, breakpoints: 'xs sm md'}
                , {name: 'yn__is_valid', title: '是否有效', sortable: true, breakpoints: 'xs sm md'}
//                , {name: 'yn__is_auth', title: '是否认证菜单', sortable: true, breakpoints: 'xs sm md'}
//                , {name: 'create_time', title: '创建时间', sortable: true, breakpoints: 'xs sm md'}
                , {name: 'creator', title: '创建人', sortable: true, breakpoints: 'xs sm md lg'}
                , {name: 'modify_time', title: '修改时间', sortable: true, breakpoints: 'xs sm md lg'}
                , {name: 'modifier', title: '修改人', sortable: true, breakpoints: 'xs sm md lg'}
            ],
            actions: ['view', 'edit', 'remove']
        }).on('remove', function () {
            $('#using_json').jstree('refresh');
        });

        $('#using_json').jstree({
            'core': {
                'data': {
                    url: "<?php echo U('getMenusByPId',['root'=>1]); ?>"
                }
            }
        }).on('select_node.jstree', function (e, data) {
            var node = data.node;
            var id = node.id;
            table.addPostParam('pid', id).loadData();
        });

        $('#submitMenu').click(function () {
            YBusy.show('正在提交');
            $.get("<?php echo U('submitMenu'); ?>", function (data) {
                YBusy.hide();
                try {
                    if (data.status) {
                        YToast.success('提交菜单成功！');
                    } else {
                        YMessager.alert(data.info);
                    }
                } catch (e) {
                    YMessager.alert(e.message)
                }
            }, 'json');
        });

//        $('#downMenu').click(function(){
//            YBusy.show('正在下载');
//            $.get("<?php echo U('downMenu'); ?>", function (data) {
//                YBusy.hide();
//                try {
//                    if (data.status) {
//                        YToast.success('提交菜单成功！');
//                    } else {
//                        YMessager.alert(data.info);
//                    }
//                } catch (e) {
//                    YMessager.alert(e.message)
//                }
//            }, 'json');
//        });

    });
</script>